package praktikumid.w10.p2;

import javax.swing.JFrame;

/**
 * An example program, which allows
 * us to draw different shapes:
 * ovals and polygons. It uses JPanel
 * as a drawing canvas.
 * <p>
 * Oval is defined by the center point
 * and two radiuses (horizontal and
 * vertical). When the mouse button
 * is pressed, the center of the oval
 * is defined to the point of the cursor.
 * When mouse is dragged, the radiuses are 
 * changed accordingly. When the button
 * is released, drawing is finished.
 * <p>
 * Polygon is defined by 1 or more points.
 * Every point is connected to the next point
 * and the last point is connected to the
 * first point by the line. When mouse is
 * clicked, a new point is added and according
 * line is drawn. When mouse is dragged,
 * the last point of the polygon can be changed
 * and according line is changed while dragging.
 * If the mouse button is released after dragging,
 * the last point will be fixed. The polygon
 * will be closed and finished after double click.
 * <p>
 * If the right mouse button is pressed (and not released),
 * shapes can be selected. If the mouse is dragged
 * (and the right button is down) the closest shape
 * to the cursor will be highlighted.
 * <p>
 * Highlighted shape can be moved with keyboard. Pressing
 * left arrow, the shape will move to the left. 
 * @author Ago
 *
 */
public class PaintFrame extends JFrame {
	
	/**
	 * Constructor. Initializes the frame.
	 */
	public PaintFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(600, 600);
		
		DrawPanel dp = new DrawPanel();
		add(dp);
	}
	
	/**
	 * The main.
	 * @param args The arguments.
	 */
	public static void main(String[] args) {
		PaintFrame f = new PaintFrame();
		f.setVisible(true);
	}
}
